home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 6.0 KB | 248 lines | [TEXT/MPS ] |
- // The C++ Booch Components (Version 2.1)
- // (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
- //
- // BCExcept.h
- //
- // This file contains the declaration of the classes and functions
- // associated with exception handling.
-
- #ifndef BCEXCEPT_H
- #define BCEXCEPT_H 1
-
- #include "BCType.h"
-
- // Patch to use the OPF foundation debug facilities
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- // [KVV] To share data in Windows accross DLLs, we need to declare it with __far
- #ifdef FW_BUILD_MAC
- #define BC_SHARED_DATA
- #endif
-
- #if defined(FW_BUILD_WIN)
- #if defined(FW_BUILD_WIN32S) || defined(FW_BUILD_WINNT)
- #define BC_SHARED_DATA
- #else
- #define BC_SHARED_DATA __far
- #endif
- #endif
-
- //========================================================================================
- // BC_CAN_EXPORT_DATA
- //========================================================================================
-
- #if defined(FW_BUILD_MAC) || defined(FW_BUILD_WIN16)
- #define BC_CAN_EXPORT_DATA
- #endif
-
- #ifdef BC_CAN_EXPORT_DATA
- extern const char* BC_SHARED_DATA BC_kDisjoint;
- extern const char* BC_SHARED_DATA BC_kDuplicate;
- extern const char* BC_SHARED_DATA BC_kEmpty;
- extern const char* BC_SHARED_DATA BC_kFull;
- extern const char* BC_SHARED_DATA BC_kIllegal;
- extern const char* BC_SHARED_DATA BC_kInvalidIndex;
- extern const char* BC_SHARED_DATA BC_kInvalidNumber;
- extern const char* BC_SHARED_DATA BC_kMissing;
- extern const char* BC_SHARED_DATA BC_kNotEmpty;
- extern const char* BC_SHARED_DATA BC_kNotRoot;
- extern const char* BC_SHARED_DATA BC_kNull;
- extern const char* BC_SHARED_DATA BC_kOutOfMemory;
- extern const char* BC_SHARED_DATA BC_kReferenced;
- extern const char* BC_SHARED_DATA BC_kTooLarge;
- extern const char* BC_SHARED_DATA BC_kTooSmall;
- #else
- const char* BC_Get_kDisjoint();
- #define BC_kDisjoint BC_Get_kDisjoint()
- const char* BC_Get_kDuplicate();
- #define BC_kDuplicate BC_Get_kDuplicate()
- const char* BC_Get_kEmpty();
- #define BC_kEmpty BC_Get_kEmpty()
- const char* BC_Get_kFull();
- #define BC_kFull BC_Get_kFull()
- const char* BC_Get_kIllegal();
- #define BC_kIllegal BC_Get_kIllegal()
- const char* BC_Get_kInvalidIndex();
- #define BC_kInvalidIndex BC_Get_kInvalidIndex()
- const char* BC_Get_kInvalidNumber();
- #define BC_kInvalidNumber BC_Get_kInvalidNumber()
- const char* BC_Get_kMissing();
- #define BC_kMissing BC_Get_kMissing()
- const char* BC_Get_kNotEmpty();
- #define BC_kNotEmpty BC_Get_kNotEmpty()
- const char* BC_Get_kNotRoot();
- #define BC_kNotRoot BC_Get_kNotRoot()
- const char* BC_Get_kNull();
- #define BC_kNull BC_Get_kNull()
- const char* BC_Get_kOutOfMemory();
- #define BC_kOutOfMemory BC_Get_kOutOfMemory()
- const char* BC_Get_kReferenced();
- #define BC_kReferenced BC_Get_kReferenced()
- const char* BC_Get_kTooLarge();
- #define BC_kTooLarge BC_Get_kTooLarge()
- const char* BC_Get_kTooSmall();
- #define BC_kTooSmall BC_Get_kTooSmall()
- #endif
-
- // Exception base class
-
- class BC_XException {
- public:
-
- BC_XException(const char* name, const char* who, const char* what);
-
- void Display() const;
-
- const char* Name() const
- {return fName;}
- const char* Who() const
- {return fWho;}
- const char* What() const
- {return fWhat;}
-
- protected:
-
- enum {BC_MAXIMUM_LENGTH = 63};
-
- char fName[BC_MAXIMUM_LENGTH + 1];
- char fWho [BC_MAXIMUM_LENGTH + 1];
- char fWhat[BC_MAXIMUM_LENGTH + 1];
-
- };
-
- // Predefined global exceptions
-
- class BC_XContainerError : public BC_XException {
- public:
-
- BC_XContainerError(const char* who, const char* what)
- : BC_XException("Container_Error", who, what) {}
-
- };
-
- class BC_XDuplicate : public BC_XException {
- public:
-
- BC_XDuplicate(const char* who, const char* what)
- : BC_XException("Duplicate", who, what) {}
-
- };
-
- class BC_XIllegalPattern : public BC_XException {
- public:
-
- BC_XIllegalPattern(const char* who, const char* what)
- : BC_XException("Illegal_Pattern", who, what) {}
-
- };
-
- class BC_XIsNull : public BC_XException {
- public:
-
- BC_XIsNull(const char* who, const char* what)
- : BC_XException("Is_Null", who, what) {}
-
- };
-
- class BC_XLexicalError : public BC_XException {
- public:
-
- BC_XLexicalError(const char* who, const char* what)
- : BC_XException("Lexical_Error", who, what) {}
-
- };
-
- class BC_XMathError : public BC_XException {
- public:
-
- BC_XMathError(const char* who, const char* what)
- : BC_XException("Math_Error", who, what) {}
-
- };
-
- class BC_XNotFound : public BC_XException {
- public:
-
- BC_XNotFound(const char* who, const char* what)
- : BC_XException("Not_Found", who, what) {}
-
- };
-
- class BC_XNotNull : public BC_XException {
- public:
-
- BC_XNotNull(const char* who, const char* what)
- : BC_XException("Not_Null", who, what) {}
-
- };
-
- class BC_XNotRoot : public BC_XException {
- public:
-
- BC_XNotRoot(const char* who, const char* what)
- : BC_XException("Not_Root",who, what) {}
-
- };
-
- class BC_XOverflow : public BC_XException {
- public:
-
- BC_XOverflow(const char* who, const char* what)
- : BC_XException("Overflow", who, what) {}
-
- };
-
- class BC_XRangeError : public BC_XException {
- public:
-
- BC_XRangeError(const char* who, const char* what)
- : BC_XException("Range_Error", who, what) {}
-
- };
-
- class BC_XStorageError : public BC_XException {
- public:
-
- BC_XStorageError(const char* who, const char* what)
- : BC_XException("Storage_Error", who, what) {}
-
- };
-
- class BC_XUnderflow : public BC_XException {
- public:
-
- BC_XUnderflow(const char* who, const char* what)
- : BC_XException("Underflow", who, what) {}
-
- };
-
- // Exception handler
-
- extern void BC_Catch(const BC_XException&);
-
- // Assertion function
-
- //========================================================================================
- //
- // The following is a patch to the components so that they use the
- // OPF assertion mechanism.
-
- #if defined(BC_DEBUG) && defined(FW_DEBUG)
- #define BC_Assert(expression, exception) FW_ASSERT(expression);
- #elif defined (BC_DEBUG)
- inline void BC_Assert(BC_Boolean expression, const BC_XException& exception)
- {
- if (!expression)
- throw(exception);
- }
- #else
- inline void BC_Assert(BC_Boolean, const BC_XException&) {}
- #endif
-
- //
- //========================================================================================
-
- #endif
-